package com.mark.config;

import com.netflix.loadbalancer.RandomRule;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootConfiguration
public class Beans {

    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }


    @Bean
    public RandomRule getRandomRule() { //将需要使用的负载均衡算法类作为IOC容器中的bean，我们就可以修改负载均衡策略
        return new RandomRule();
    }

}
